-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(inc): Add index to GroupOpenPeriod data jsonfield #97534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -73,6 +73,10 @@ class Meta: | |||
indexes = ( | |||
# get all open periods since a certain date | |||
models.Index(fields=("group", "date_started")), | |||
models.Index( | |||
models.F("data__pending_incident_detector_id"), | |||
name="data__pend_inc_detector_id_idx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
is required and it's limited to 30 chars so I did the best I could here
b9c0373
to
aab255c
Compare
This PR has a migration; here is the generated SQL for for --
-- Create index data__pend_inc_detector_id_idx on F(data__pending_incident_detector_id) on model groupopenperiod
--
CREATE INDEX CONCURRENTLY "data__pend_inc_detector_id_idx" ON "sentry_groupopenperiod" ((("data" -> 'pending_incident_detector_id'))); |
# is a schema change, it's completely safe to run the operation after the code has deployed. | ||
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment | ||
|
||
is_post_deployment = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be post-deployment migration, as this table has >260M rows, and adding index will probably time out if we do it as in-deploy migration.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #97534 +/- ##
========================================
Coverage 80.62% 80.62%
========================================
Files 8560 8560
Lines 376889 377106 +217
Branches 24538 24538
========================================
+ Hits 303870 304048 +178
- Misses 72649 72688 +39
Partials 370 370 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, hopefully this isn't too hard to create
Redo of #96221 after [adding an index](#97534) to the `GroupOpenPeriod`'s `data` column on `pending_incident_detector_id` which should hopefully not result in [the error](https://sentry.sentry.io/issues/6799376702/) anymore. There are no changes to this PR from the original one. --------- Co-authored-by: Snigdha Sharma <[email protected]>
#96221 had to be reverted due to https://sentry.sentry.io/issues/6799376702 so we thought adding an index on `GroupOpenPeriod`'s `data` jsonfield to the frequently looked up `pending_incident_detector_id` key would help speed things up.
Redo of #96221 after [adding an index](#97534) to the `GroupOpenPeriod`'s `data` column on `pending_incident_detector_id` which should hopefully not result in [the error](https://sentry.sentry.io/issues/6799376702/) anymore. There are no changes to this PR from the original one. --------- Co-authored-by: Snigdha Sharma <[email protected]>
#96221 had to be reverted due to https://sentry.sentry.io/issues/6799376702 so we thought adding an index on
GroupOpenPeriod
'sdata
jsonfield to the frequently looked uppending_incident_detector_id
key would help speed things up.